package com.google.gwt.command.client;

import com.google.gwt.event.shared.GwtEvent;

/**
 * The Command is in charge of the realization in reaction to a fired event like
 * a remote call or another action.
 * 
 * @author romain biard
 * 
 * @param <T>
 *            the event managed by this command
 */
public interface Command<T extends GwtEvent<?>> {

	/**
	 * this method is called in "standard" case. You have to implements the
	 * concrete things that have to be done when a managed event is fired on the
	 * eventbus.
	 * 
	 * @param event
	 *            the managed event
	 */
	void execute(T event);

	/**
	 * this method describe, when it is possible, the way to roll back actions
	 * which had been done with this event. (i.e through the execute method)
	 * 
	 * @param event
	 *            the managed event which had been fired
	 * @return the result of the undo operation
	 */
	boolean undo(T event);

}
